<template>
<<<<<<< HEAD
<div>争夺</div>
</template>
=======
  <div class="main1">
    <el-card>
    <div>
      <el-form :inline="true">
        <el-form-item><el-input placeholder="请输入课程" v-model="keyword"></el-input></el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
          <el-button type="primary">高级搜索</el-button>
        </el-form-item>
      </el-form>
      </div>
      <div>
        <el-button type="danger" @click="batchDelete">批量删除</el-button>
        <el-button type="primary" @click="exportData">导出数据</el-button>
        <el-button type="success" @click="handleAdd">添加课程</el-button>
      </div>
    </el-card>

    <el-card>
      <el-table :data="tbData" style="width: 100%" v-loading="loading">
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column label="序号" align="center" width="75">
            <template slot-scope="scope">{{scope.$index + 1 }}</template>
        </el-table-column>
        <el-table-column label="课程名称" align="center" property="course" width="190px">
        </el-table-column>
        <el-table-column label="教材名称" align="center" property="openTime" width="190px">
        </el-table-column>
        <el-table-column label="是否为公开课" align="center" property="endTime" width="190px">
        </el-table-column>
        <el-table-column label="专业名称" align="center" property="credits" width="190px">
        </el-table-column>
        <el-table-column label="任教老师" align="center" property="teacher" width="190px">
        </el-table-column>
        <el-table-column label="操作"  align="center">
          <template slot-scope="scope">
            <el-button size="mini" type="warning" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
            <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>

        <!-- 模态框 -->
      <div>
        <el-dialog title="新增课程" :visible.sync="dialogFormVisible">
          <el-form :model="form" :rules="rules" ref="formDemo">
            <el-form-item label="课程名称" :label-width="formLabelWidth" prop="course">
              <el-input v-model="form.course" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="学分" :label-width="formLabelWidth">
               <el-input-number v-model="form.credits" controls-position="right" @change="handleChange" :min="1" :max="3"></el-input-number>
            </el-form-item>
            <el-form-item label="教师" :label-width="formLabelWidth" prop="teacher">
              <el-input v-model="form.teacher" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="地址"  :label-width="formLabelWidth" prop="address">
              <el-input v-model="form.address" autocomplete="off"></el-input>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click="handleCancel">取 消</el-button>
            <el-button type="primary" @click="handleSave">确 定</el-button>
          </div>
        </el-dialog>
      </div>
    </el-card>
     <!-- 分页组件 -->
        <div class="block">
        <el-pagination
            :current-page="pager.pageIndex"
            :page-size="pager.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="pager.rowsTotal"
            background
        >
        </el-pagination>
        </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      keyword:"",
      credits:1,
      formLabelWidth:"120px",
      pager:{
        pageIndex:1,
        rowsTotal:20
      },
      rules:{
        course:[
        {
            required: true,
            trigger: "blur",
            message: "请输入课程名称",
        },
        ],
        teacher:[
        {
            required: true,
            trigger: "blur",
            message: "请输入任何老师名字",
        },
        ],
        address:[
        {
            required: true,
            trigger: "blur",
            message: "请输入地址",
        },
        ]
      },
      loading: false,
      tbData: [],
      dialogFormVisible: false,
      form: {
        id: "",
        course:"",
        openTime:"",
        endTime:"",
        credits: "",
        teacher:"",
        address:""
      },
    };
  },
  methods: {
    handleChange(){},
    handleQuery(){},
    handleAdd() {
      // 弹出对话框时，当还没有初始化完成就调用resetFields方法会出现问题，所以我们在下一轮轮询时，再来做这个动作，可以避免找不到方法
      this.dialogFormVisible = true;
      this.$nextTick(() => {
        this.$refs.formDemo.resetFields();
      });
    },
    handleEdit(index, row) {
      // 弹出对话框时，当还没有初始化完成就调用resetFields方法会出现问题，所以我们在下一轮轮询时，再来做这个动作，可以避免找不到方法
      this.dialogFormVisible = true;
      this.$nextTick(() => {
        this.$refs.formDemo.resetFields();
        // 赋值也一样，还没有重置完成，会导致其中的赋值不会成功
        this.currentEditIndex = index;
        this.form.id = row.id;
        this.form.course = row.course;
        this.form.credits =row.credits;
        this.form.teacher =row.teacher;
        this.form.address =row.address
      });
    },
    handleDelete() {
      
    },
    // 批量删除
    batchDelete() {},
    // 导出数据
    exportData() {},
    handleCancel() {
        this.dialogFormVisible = false;
    },
    handleSave() {

      this.dialogFormVisible = false;
    },
  },
};
</script>
<style>
.el-card__body {
  display: flex;
  justify-content: space-between;
}
.el-table th.el-table__cell > .cell {
  padding-left: 14px !important;
}
.slh {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.main1 {
  width: 100%;
  height: 100%;
}
</style>
>>>>>>> dev
